<?php
namespace core\lib;
class route{
	public $ctl;
	public $act;
	public function __construct()
	{
		/*实现方式：1 隐藏index.php
			      2 获取url参数部分
			      3 返回对应的控制器和方法*/

		//test($_SERVER);
		if(isset($_SERVER['REQUEST_URL']) && $_SERVER['REQUEST_URL']!='/myFrame/'){
			$path = $_SERVER['REQUEST_URL'];
			$patharr = explode('/', trim($path,'/'));
			if(isset($patharr[0]))
			{
				$this->ctl = $patharr[0];
			}
			unset($patharr[0]);
			if(isset($patharr[1]))
			{
				$this->act = $patharr[1];
				unset($patharr[1]);
			}
			else
			{
				$this->act = 'index';
			}
			//URL的多余部分转化的参数
			$content = count($patharr)+2;
			$i=2;
			while($i< $count)
			{
				if(isset($patharr[$i+1]))
				{
					$_GET[$patharr[$i]] = $patharr[$i+1];
				}
				$i = $i+2;
			}		
		} else{
			$this->ctl = 'index';
			$this->act = 'index';
		}
	}
}